<template>
    <div class="m-b">
        <div>
            <el-button type="primary" @click="addGoods">+添加商品</el-button>
            <el-button v-if="disableRecord !== true" type="primary" @click="recordMessage">录入</el-button>
        </div>
        <div style="margin-top:10px" v-show="goodsVisible">
            <el-input type="textarea" v-model="goodsText" cols="40" rows="4"></el-input>
            <div class="m-t">
                <el-button @click="goodsText = ''">清 空</el-button>
                <el-button @click="submit">提 交</el-button>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    props: {
        disableRecord: {
            type: Boolean,
        },
        type: {
            type: Number,
        },
        customerId: {
            type: String,
        }
    },
    data() {
        return {
            goodsVisible: false,
            goodsText: '',
        }
    },
    methods: {
        addGoods() {
            this.$emit('addGoods', this.type);
        },
        submit() {
            this.$emit('goodsSubmit', this.goodsText, this.type);
        },
        recordMessage() {
            // 选择客户才能录入
            if(this.customerId < 0) return this.$message.warning('请选择客户');
            this.goodsVisible = true;
        }
    }
}
</script>